package com.dingwen.stumybplu.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
 * 提示信息常量
 *
 * @author dingwen
 * 2021.06.07 16:54
 */
@Getter
@AllArgsConstructor
public enum Tip {
    /**
     * UserController
     * getMaps
     * columnNameListStr null
     */
    Tip1(1, "列清单不能为空");

    /**
     * 得到提示
     *
     * @param code 代码
     * @return {@link Tip}
     */
    public static Tip getTip(Integer code) {
        Optional.ofNullable(code).orElseThrow(() -> new RuntimeException("code 不能为空"));
        Predicate<Tip> predicate = code::equals;
        List<Tip> tipList = Arrays.stream(Tip.values()).parallel().filter(predicate).collect(Collectors.toList());
        return tipList.get(0);
    }

    /**
     * 代码
     */
    private final Integer code;
    /**
     * 描述
     */
    private final String description;
}
